#!/usr/bin/perl -w
package app::process;

use Config;

# an application monitor is simply passed the value of 'value' -
# which in this case is the string to check for. It will return
# a count of processes where the argument is this string.

sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self  = {};
my $name=shift;
my $value=shift;

	$self->{name}=$name;
	$self->{value}=$value;
	$self->{min_interval}=60;
	$self->{description}="Application process monitor.";
	bless ($self, $class);
	return($self);
}

sub action_args {
my $self=shift;

	return "occurrence_minmax";
}

sub min_interval {
my $self=shift;

	return($self->{min_interval});
}

sub test {
my $self=shift;
my $cmd;

	my $str=$self->{value};
	if($::Config{osname} eq "hpux") {
		$cmd="export UNIX95=1; ps -e -o args";

	} else {
		$cmd="ps -e -o args";
	}
	my $s=`$cmd 2>/dev/null`; 
	my @F=split(/\n/,$s);
	my $matches=0;
	for (@F) {
		$matches++ if /$str/;
	}
	return $matches;
}

sub reset {
my $self=shift;

}

sub desc {
my $self=shift;

	return $self->{description};
}

1;

